/*
 * Copyright (c) 2019-2023, ShangHai YTO Co., Ltd.
 * All right reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF YTO
 * CO., LTD.  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED
 * TO THIRD PARTIES, COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 * WITHOUT THE PRIOR WRITTEN PERMISSION OF YTO
 * CO., LTD.
 */

package cn.yto.wdgj.wdgjgptdigitaltool.feign.response;

import cn.yto.wdgj.wdgjgptdigitaltool.feign.request.Event;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author 谢文东
 * @description: 机器人回复事件
 * @reason: 回复到聊天框的内容
 * @date 2023-11-6 10:21:01
 * @since JDK 1.8
 */
@Data
@NoArgsConstructor
public class BotEvent extends Event {
    @JsonProperty("recipient_id")
    private String recipientId;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String text;    // 机器人显示的文本
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @NotNull(message = "Custom对象为空")
    private @Valid Custom custom;  // 返回对象在自定义中
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String error;
    // PS. NLU与FLAG无其他作用,仅仅用于测试定位问题
    // 1. 避免测试频繁追问哪里控制的回复.
    // 2. 以及我们应用回复时,NLU响应是什么
    private String source = "应用消息";//应用消息|模型消息
    private String nlu;//该消息来自模型
    /**
     * 意图名称
     */
    private String intentName;
    /**
     * 实体名称
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String entityName;

    /**
     * 上下文多轮标识
     * true-多轮 默认false
     */
    private Boolean context = false;

    /**
     * 缓存标识 默认false true-走缓存
     */
    private boolean cacheFlag = false;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Custom {
        @NotEmpty(message = "TAG为空")
        private String tag;
        private String name = "未知"; // TAG中文名称=意图名称=回复类型
        private Object data;
        private String type;
        private boolean button;
    }
}
